package generator.website;

import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
import website.*;

public class WebSiteDAOEntityFactory
{
  protected static String nl;
  public static synchronized WebSiteDAOEntityFactory create(String lineSeparator)
  {
    nl = lineSeparator;
    WebSiteDAOEntityFactory result = new WebSiteDAOEntityFactory();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package domain;" + NL + "" + NL + "public class DAO";
  protected final String TEXT_2 = " {" + NL + "\t" + NL + "\tpublic String add";
  protected final String TEXT_3 = "(";
  protected final String TEXT_4 = "final String [] ";
  protected final String TEXT_5 = "final String ";
  protected final String TEXT_6 = ", ";
  protected final String TEXT_7 = "){" + NL + "\t\t" + NL + "\t\t// TODO" + NL + "\t\treturn null;" + NL + "\t\t" + NL + "\t}";
  protected final String TEXT_8 = NL + "\t" + NL + "\tpublic String update";
  protected final String TEXT_9 = "(";
  protected final String TEXT_10 = "final String [] ";
  protected final String TEXT_11 = "final String ";
  protected final String TEXT_12 = ", ";
  protected final String TEXT_13 = "){" + NL + "\t\t" + NL + "\t\t// TODO" + NL + "\t\treturn null;" + NL + "\t\t" + NL + "\t}";
  protected final String TEXT_14 = NL + "\t" + NL + "\tpublic String delete";
  protected final String TEXT_15 = "(final String ";
  protected final String TEXT_16 = "){" + NL + "\t" + NL + "\t\t// TODO" + NL + "\t\treturn null;" + NL + "\t" + NL + "\t}";
  protected final String TEXT_17 = NL + "}";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    Form form = (Form) argument;
EList<Tag> Listtag = form.getTags();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(form.getEntity().getName());
    stringBuffer.append(TEXT_2);
    stringBuffer.append(form.getEntity().getName());
    stringBuffer.append(TEXT_3);
    
	for(int i=0; i<Listtag.size(); i++){
		if(Listtag.get(i) instanceof FormTag && !(Listtag.get(i) instanceof Button)){
			if(Listtag.get(i) instanceof Select || Listtag.get(i) instanceof RadioButton){
  
    stringBuffer.append(TEXT_4);
    stringBuffer.append(Listtag.get(i).getName());
    
			} else {
  
    stringBuffer.append(TEXT_5);
    stringBuffer.append(Listtag.get(i).getName());
    
  			}
  			if(i < Listtag.size()-3){
  				
    stringBuffer.append(TEXT_6);
    
  			}
  		}
		if(i == Listtag.size()-1)
			
    stringBuffer.append(TEXT_7);
    
	}
    stringBuffer.append(TEXT_8);
    stringBuffer.append(form.getEntity().getName());
    stringBuffer.append(TEXT_9);
    
	for(int i=0; i<Listtag.size(); i++){
		if(Listtag.get(i) instanceof FormTag && !(Listtag.get(i) instanceof Button)){
			if(Listtag.get(i) instanceof Select || Listtag.get(i) instanceof RadioButton){
  
    stringBuffer.append(TEXT_10);
    stringBuffer.append(Listtag.get(i).getName());
    
			} else {
  
    stringBuffer.append(TEXT_11);
    stringBuffer.append(Listtag.get(i).getName());
    
  			}
  			if(i < Listtag.size()-3){
  				
    stringBuffer.append(TEXT_12);
    
  			}
  		}
		if(i == Listtag.size()-1)
			
    stringBuffer.append(TEXT_13);
    
	}
    stringBuffer.append(TEXT_14);
    stringBuffer.append(form.getEntity().getName());
    stringBuffer.append(TEXT_15);
    
	for(int i=0; i<Listtag.size(); i++){
		if(Listtag.get(i) instanceof FormTag && !(Listtag.get(i) instanceof Button)){
			
    stringBuffer.append(Listtag.get(i).getName());
    stringBuffer.append(TEXT_16);
    break;
		}
	}
    stringBuffer.append(TEXT_17);
    return stringBuffer.toString();
  }
}
